<?php

namespace app\admin\validate;

use think\Validate;

class Agent extends Validate
{
    protected $rule = [
        'username' => 'require|min:3|max:20',
        'password' => 'require|min:8|max:16|regex:/(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\W_]).{8,16}/',
        'oil_service' => 'require',
        'company_name' => 'max:50',
        'mobile' => 'require',
        'mobile_discount_slow' => 'require|require|regex:\d{2,3}([.]{1}[0-9]{1,2})?|egt:90|elt:130',
        'mobile_discount_fast' => 'require|require|regex:\d{2,3}([.]{1}[0-9]{1,2})?|egt:90|elt:130',
        'status' => 'require|in:1,2',
        'settle_type' => 'require|in:1,2',
        'id' => 'require',
        'amount' => 'require|float',
        'remark' => 'max:255',
        'ip_address' => 'max:255',
        'trade_no' => 'require',
    ];

    protected $field = [
        'password' => '密码'
    ];

    protected $message = [
        'username.require' => '请输入登录账号',
        'username.min' => '登录账号最少 3 个字符',
        'username.max' => '登录账号最多 20 个字符',
        'password.require' => '请输入登录密码',
        'password.regex' => '必须含大小写字母数字和符号',
        'company_name.max' => '公司名称最多 50 个字符',
        'mobile.require' => '请输入手机号码',
        'mobile_discount_slow.require' => '请输入慢充折扣',
        'mobile_discount_slow.regex' => '慢充折扣范围：90.00 ~ 130.00',
        'mobile_discount_slow.egt' => '慢充折扣范围：90.00 ~ 130.00',
        'mobile_discount_slow.elt' => '慢充折扣范围：90.00 ~ 130.00',
        'mobile_discount_fast.require' => '请输入快充折扣',
        'mobile_discount_fast.regex' => '快充折扣范围：90.00 ~ 130.00',
        'mobile_discount_fast.egt' => '快充折扣范围：90.00 ~ 130.00',
        'mobile_discount_fast.elt' => '快充折扣范围：90.00 ~ 130.00',
        'status.require' => '请选择代理商状态',
        'status.in' => '代理商状态有误',
        'settle_type.require' => '请选择代理商结算状态',
        'settle_type.in' => '代理商结算状态有误',

        'id.require' => '代理商 id 不能为空',
        'amount.require' => '充值金额不能为空',
        'amount.float' => '充值金额只能是数字',
        'remark.max' => '备注不能超过 255 个字符',
        'ip_address.max' => 'IP白名单不能超过 255 个字符',

        'trade_no.require' => '交易单号不能为空',
    ];

    protected $scene = [
        'create' => [
            'username',
            'password',
            'company_name',
            'mobile',
            'settle_type',
            'ip_address',
        ],
        'mobile_service' => [
            'mobile_discount_slow',
            'mobile_discount_fast',
        ],
        'edit' => [
            'id',
            'company_name',
            'mobile',
            'status',
            'ip_address',
        ],
        'recharge' => [
            'id',
            'amount',
            'remark',
        ],
        'queryDmjOrderByTradeNo' => [
            'id',
            'trade_no',
        ]
    ];
}
